/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package trabalho;

import java.io.Reader;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.core.LowerCaseFilter;
import org.apache.lucene.analysis.core.WhitespaceTokenizer;
import org.apache.lucene.analysis.en.PorterStemFilter;
import org.apache.lucene.analysis.shingle.ShingleFilter;
import org.apache.lucene.analysis.standard.StandardTokenizer;
import org.apache.lucene.util.Version;

/**
 *
 * @author Felipe
 */
public class MeuAnalisador extends Analyzer{

    @Override
    protected TokenStreamComponents createComponents(String fieldName, Reader reader) {
        //passa pelo tokenizador padrão
        Tokenizer source = new StandardTokenizer(Version.LUCENE_47,reader);
        //transforma tudo em minusculo e filtra
        TokenStream filter1 = new LowerCaseFilter(Version.LUCENE_47,source);
        //filtra usando o stemer de porter
        TokenStream filter2 = new PorterStemFilter(filter1);
        return new TokenStreamComponents(source, filter2);
    }
    
}
